package com.yanqu.road.logic.activity.foxcard.game.effect;

import com.yanqu.road.entity.activity.foxcard.FoxBaseCard;
import com.yanqu.road.entity.activity.foxcard.FoxHandCard;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardTriggerType;

import java.util.Collections;
import java.util.List;

/**
 *  牌组中如果至少有x张增强牌，加效果
 */
public class FoxCardEffect45 extends FoxCardEffectBase {
    @Override
    protected void effectHandle(FoxCardGameLogic gameLogic, FoxHandCard handCard) {
        if (triggerType != eFoxCardTriggerType.AFTER_SCORE) {
            return;
        }

        int numNeed = Integer.valueOf(effectConfig.getParamsList().get(0));

        int calcNum = 0;

        for (FoxHandCard remainHandCard : gameLogic.getGameData().getRemainHandCards()) {
            if (remainHandCard.getReinforceEffect() > 0) {
                calcNum++;
            }
        }
        for (FoxHandCard dropHandCard : gameLogic.getGameData().getDropHandCards()) {
            if (dropHandCard.getReinforceEffect() > 0) {
                calcNum++;
            }
        }

        for (FoxHandCard foxHandCard : gameLogic.getGameData().getHandCards()) {
            if (foxHandCard.getReinforceEffect() > 0) {
                calcNum++;
            }
        }

        if (calcNum >= numNeed) {
            List<FoxBaseCard> foxEffectCards = Collections.singletonList(effectCard);
            gameLogic.addBaseScore(Integer.valueOf(effectConfig.getParamsList().get(1)), foxEffectCards, null); //加基础筹码
            gameLogic.addBaseScoreMulti(Integer.valueOf(effectConfig.getParamsList().get(2)), foxEffectCards, null); //当前基础筹码乘算
            gameLogic.addBaseMulti(Integer.valueOf(effectConfig.getParamsList().get(3)), foxEffectCards, null); //加基础倍率
            gameLogic.addBaseMultiMulti(Integer.valueOf(effectConfig.getParamsList().get(4)), foxEffectCards, null); //当前基础倍率乘算
            gameLogic.goldChange(Integer.valueOf(effectConfig.getParamsList().get(5)), foxEffectCards, null, triggerType); //加金币
        }
    }
}
